package com.aaa.controller;

import com.aaa.entity.Album;
import com.aaa.entity.Approval;
import com.aaa.entity.User;
import com.aaa.service.AlbumService;
import com.aaa.service.ApprovalService;
import com.aaa.service.UserService;
import com.aaa.service.VoiceService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;


@Controller
@RequestMapping("user")
public class UserController {
    @Resource
    VoiceService voiceService;
    @Resource
    AlbumService albumService;
    @Resource
    ApprovalService approvalService;
    @Resource
    UserService userService;

    @RequestMapping("selectUser")
    @ResponseBody
    public PageInfo select(Integer pageNum, Integer pageSize, String username) {
        if(username!=null){
            //模糊查询专辑名根据
            PageHelper.startPage(pageNum,pageSize);
            QueryWrapper queryWrapper=new QueryWrapper();
            queryWrapper.like("username",username);
            List<User> list = userService.list(queryWrapper);
            PageInfo pageInfo=new PageInfo(list);
            return  pageInfo;
        }else {
            //查询全部
            PageHelper.startPage(pageNum,pageSize);
            List<User> list = userService.list();
            PageInfo pageInfo=new PageInfo(list);
            return  pageInfo;
        }
    }
}
